package com.ds.controller;

import cn.hutool.json.JSONUtil;

import com.ds.entity.Student;
import com.ds.entity.User;
import com.ds.service.IUserService;
import com.ds.service.IStudentService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 测试controller
 */
@RestController
@RequestMapping("test")
public class TestController {

    @Autowired
    IUserService userService;

    @Autowired
    IStudentService studentService;


    @GetMapping("listUser")
    public String listUser() {
        List<User> list = userService.findAll();
        return JSONUtil.toJsonStr(list);
    }

    @GetMapping("listStudent")
    public String listStudent() {
        List<Student> list = studentService.findAll();
        return JSONUtil.toJsonStr(list);
    }

    @GetMapping("insertStudent")
    public void insertStudent() {
        studentService.insert();
    }

    @GetMapping("add")
    public String add() {
        userService.add();
        return "OK~~~~~~~~~~";
    }
}
